/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2020-07-15
 * Time: 22:53
 */
#include "TreeView.h"

TreeView::TreeView(QWidget *widget) {
    InitUi();
}

TreeView::~TreeView() {

}

void TreeView::InitUi() {
    QHBoxLayout *mainlayout = new QHBoxLayout(this);

    QSplitter *splitter = new QSplitter(this);
    mainlayout->addWidget(splitter);

    QListView *listview = new QListView;
    QTreeView *treeview = new QTreeView;
    //设置背景交替
    treeview->setAlternatingRowColors(true);
    QStringListModel *listModel = new QStringListModel(this);
    listModel->setStringList(QStringList()<<"234"<<"ersdf"<<"sdf"<<"sdf"<<"sdf"<<"dsf");
    treeview->setModel(listModel);

    QTextEdit *textedit = new QTextEdit;
    splitter->addWidget(listview);
    splitter->addWidget(treeview);
    splitter->addWidget(textedit);

    //设置子窗口是否可压缩至0（拉伸至不可见），true为开启，false为关闭
    splitter->setChildrenCollapsible(false);
    splitter->setSizes(QList<int>()<<200<<300<<200);

}
